import uuid
import random
import time
import string


# -----------随机获取带两位小数的数字-------------
def get_float_num():
    return round(random.uniform(0, 99), 2)


def get_openId():
    return str(uuid.uuid1()).replace("-", "")


def get_num(max_num=9):
    return random.randint(1, max_num)


def get_mobile():
    return str(random.randint(19911111111, 19999999999))


def get_mobile_int():
    return random.randint(19911111111, 19999999999)


def get_islle_mobile():
    return str(random.randint(29911111111, 29999999999))


# 拼接字符串
def add_string(*args):
    base_string = ''
    for i in args:
        base_string += i
    return base_string


# 获取缺失的手机号 or 随机
def get_less_mobile(num=10):
    base_num = num - 3
    num_list = ['139', '199', '186']
    start_num = random.choice(num_list)
    end_num = random.sample(string.digits, base_num)
    end_num = ''.join(end_num)
    base_mobile = add_string(start_num, end_num)
    return base_mobile


# 随机获取11位手机号
def get_random_mobile():
    return get_less_mobile(num=11)


# 获取带字母的手机号
def get_error_mobile(num=1):
    base_num = 8 - num
    num_list = ['139', '199']
    start_num = random.choice(num_list)
    end_num = random.sample(string.digits, base_num)
    end_num = ''.join(end_num)
    # 随机字母
    sample_lower = ''.join(random.sample(string.ascii_lowercase, 1))
    base_mobile = add_string(start_num, end_num, sample_lower)
    return base_mobile


def getLocaltimestamp():
    return int(time.time() * 1000)


def newStr(len):
    # 1、先指定字符集，字符集中包括数字、大小写字母、特殊符号：
    seed = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    # 2、从指定的字符集中随机取，分别取8位，组合成新字符串
    str1 = []
    for i in range(len):
        str1.append(random.choice(seed))
    StringS = ''.join(str1)
    return StringS


# 根据输入的长度生成一个长度相同的随机数，随机数是纯数字组合
def newStrnums(len):
    str1 = []
    i = 0
    while i != len:
        str1.append(str(random.randint(0, 9)))
        i = i + 1
    StringS = ''.join(str1)
    return StringS


def getDateFormat():
    return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())


def getLocaltimestamp1():
    return int(time.time())


# +1
def add_num(first_num=0):
    if first_num < 0:
        return "瞎搞"
    base_num = first_num + 1
    return base_num


# -1
def reduce_num(first_num=0):
    if first_num < 0:
        return "瞎搞"
    base_num = first_num - 1
    return base_num


